import math


def Spherical_segment(data: dict):
    """
    计算圆球体，输入一个字典，返回一个字典
    :param data:字典
    {
    r: 球台上圆半径
    R: 球台下圆半径
    h: 球台高度
    }

    :return res:字典
    {
    "Spherical_segment_volume"：球台体积
    }
    """
    if "r" in data and "R" in data and "h" in data:
        r = data["r"]
        R = data["R"]
        h = data["h"]
        Spherical_segment_volume = math.pi * h * (3 * (R * R + r * r) + h * h) / 6
    else:
        pass
    return {
        "Spherical_segment_volume" : Spherical_segment_volume
    }


def test():
    """
    测试函数
    :return:
    """
    data = {
        "r": 2,
        "R": 3,
        "h": 2
    }
    res = Spherical_segment(data)
    print(res)


test()
